/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tabelmodel;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import model.Dosis;

/**
 *
 * @author Asus
 */
public class DosisTerpilihTableModel extends AbstractTableModel {

    private List<Dosis> dosis = new ArrayList<Dosis>();

    public DosisTerpilihTableModel(List<Dosis> dss) {
        this.dosis = dss;
    }

    public void deleteDosis(int row){
        dosis.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateDosis(int row, Dosis dss){
        dosis.set(row,dss);
        fireTableRowsUpdated(row, row);
    }

    public void addEfek(Dosis efekk) {
        dosis.add(efekk);
        fireTableRowsInserted(getRowCount() - 1, getColumnCount() - 1);
    }

    public int getRowCount() {
        return dosis.size();
    }


    public int getColumnCount() {
        return 1;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Dosis b = dosis.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return b.getNamaDosis();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "DOSIS";
            default:
                return "";
        }
    }
}


